// src/utils/api.js
import request from './request'

// 用户相关API
export const userApi = {
  login(data) {
    return request({
      url: '/api/v1/login/access-token',
      method: 'post',
      data
    })
  },

  logout() {
    return request({
      url: '/api/v1/logout',
      method: 'post'
    })
  },

  register(data) {
    return request({
      url: '/user/register',
      method: 'post',
      data
    })
  },

  getUserInfo() {
    return request({
      url: '/api/v1/users/me',
      method: 'get'
    })
  },

  updateUserInfo(data) {
    return request({
      url: '/user/info',
      method: 'put',
      data
    })
  }
}

// 公司数据相关API
export const CampatydataApi = {
  getCampatyDataList() {
    return request({
      url: '/api/v1/companies/',
      method: 'get'
    })
  },

  getLevelsByCompanyId(companyId) {
    return request({
      url: `/api/v1/companies/${companyId}/levels`,
      method: 'get'
    })
  },

  getSalaryStatsByCompanyId(companyId) {
    return request({
      url: `/api/v1/companies/companies/${companyId}/salary-stats`,
      method: 'get'
    })
  }
}

// 薪酬数据相关API
export const SalariesdataApi = {
  getDataList(params) {
    return request({
      url: '/api/v1/salaries/',
      method: 'get',
      params
    })
  },

  getSalaryDetail(id) {
    return request({
      url: `/api/v1/salaries/${id}`,
      method: 'get'
    })
  },

  getSalaryByCompanyId(companyId, params) {
    return request({
      url: `/api/v1/salaries/company/${companyId}`,
      method: 'get',
      params
    })
  },

  submitSalary(data) {
    return request({
      url: '/api/v1/salaries/',
      method: 'post',
      data,
      headers: {
        'Content-Type': 'application/json'
      }
    })
  }
}

// 吐槽数据相关API
export const RoastApi = {
  getRoastList(params) {
    return request({
      url: '/api/v1/complaint/',
      method: 'get',
      params
    })
  },

  getRoastDetail(id) {
    return request({
      url: `/api/v1/complaint/${id}`,
      method: 'get'
    })
  },

  submitRoast(data) {
    return request({
      url: '/api/v1/complaint/',
      method: 'post',
      data,
      headers: {
        'Content-Type': 'application/json'
      }
    })
  }
}

// 职位数据相关API
export const JobApi = {
  getJobList(params) {
    return request({
      url: '/api/v1/jobs/jobs/',
      method: 'get',
      params
    })
  }
}